import request from '@/api/request.js'

// 查询表单组
export function getGroupsWithDef(param) {
  return request({
    url: '../erupt-api/erupt-flow/admin/def/group',
    method: 'get',
    params: param
  })
}

// 表单排序
export function groupItemsSort(param) {
  return request({
    url: '../erupt-api/erupt-flow/admin/def/sort',
    method: 'put',
    data: param
  })
}

// 表单分组排序
export function groupSort(param) {
  return request({
    url: '../erupt-api/erupt-flow/admin/def/group/sort',
    method: 'put',
    data: param
  })
}

// 创建表单组
export function createGroup(groupName) {
  return request({
    url: '../erupt-api/erupt-flow/admin/def/group',
    method: 'post',
    params: {
      groupName: groupName
    }
  })
}

// 创建表单组
export function updateGroup(groupId, name) {
  return request({
    url: '../erupt-api/erupt-flow/admin/def/group',
    method: 'put',
    params: {
      id: groupId,
      name: name
    }
  })
}

// 删除表单组
export function removeGroup(groupId) {
  return request({
    url: '../erupt-api/erupt-flow/admin/def/group/'+groupId,
    method: 'delete'
  })
}

//创建表单
export function createDef(param){
  return request({
    url: '../erupt-api/erupt-flow/admin/def',
    method: 'post',
    data: param
  })
}

// 查询表单详情
export function getDetail(processKey) {
  return request({
    url: '../erupt-api/erupt-flow/admin/def/detail/' + processKey,
    method: 'get'
  })
}

// 更新表单详情
export function updateDetail(param) {
  return request({
    url: '../erupt-api/erupt-flow/admin/def/detail',
    method: 'put',
    data: param
  })
}

// 更新表单详情
export function removeDef(processKey) {
  return request({
    url: '../erupt-api/erupt-flow/admin/def/'+processKey,
    method: 'delete'
  })
}

export function stopDef(processKey) {
  return request({
    url: '../erupt-api/erupt-flow/admin/def/stop/'+processKey,
    method: 'put'
  })
}

export function startDef(processKey) {
  return request({
    url: '../erupt-api/erupt-flow/admin/def/start/'+processKey,
    method: 'put'
  })
}

// 查询已加载的EruptForm******************************************该处后续考虑是否保留
export function getEruptForms() {
  return request({
    url: '../erupt-api/erupt-flow/forms',
    method: 'get'
  })
}
